#include "GameObject.h"
#include "./Components/RenderComponent.h"
#include "./Components/RenderPointComponent.h"
#include "../Physics/ParticleComponent.h"
#include "../PantsuEngine.h"

#include <string>

using namespace Pantsu;

GameObject::GameObject() 
	:
m_NumOfComponents ( 0 )
{
}

GameObject::~GameObject() {
}

GameObject::GameObject( const GameObject &i_gameobject ) {
}

void GameObject::Update() {

}

void GameObject::AttachComponent( const std::string &i_type ) {

	Component *component = 0;
	int index = 0;

	if ( i_type == "RenderPoint" ) {
		component = new RenderPointComponent();
		PantsuEngine::Get()->GetSceneManager( 0 )->GetRenderComponentManager()->AddComponent( component );
		index = 0;
	}
	else if ( i_type == "Particle" ) {
		component = new ParticleComponent();
		PantsuEngine::Get()->GetSceneManager( 0 )->GetPhysicsManager()->AddComponent( component );
		index = 1;
	}

	m_Components[ index ] = component;
	component->SetOwner( this );

}

Component *GameObject::GetComponent( const std::string &i_type ) {

	if ( i_type == "RenderPoint" ) {
		return m_Components[ 0 ];
	}
	if ( i_type == "Particle" ) {
		return m_Components[ 1 ];
	}

	return 0;
}
